package com.my.study.redis;

//import com.jd.jim.cli.redis.jedis.Jedis;

import redis.clients.jedis.Jedis;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class FirstClass {

    public static void main(String[] args) {


        Jedis jedis = new Jedis("127.0.0.1", 6379);

        Map<String, String> order1 = new HashMap<>();
        Map<String, String> order2 = new HashMap<>();
        Map<String, String> order3 = new HashMap<>();
        Map<String, String> order4 = new HashMap<>();

        order1.put("orderId", "1");
        order1.put("money", "36.6");
        order1.put("time", "2018-01-01");

        order2.put("orderId", "2");
        order2.put("money", "38.6");
        order2.put("time", "2018-01-01");

        order3.put("orderId", "3");
        order3.put("money", "39.6");
        order3.put("time", "2018-01-01");

        jedis.hmset("order:1", order1);
        jedis.hmset("order:2", order2);
        jedis.hmset("order:3", order3);


        jedis.lpush("user:1:order", "order:1", "order:2","order:3");


        order4.put("orderId", "4");
        order4.put("money", "40.6");
        order4.put("time", "2018-01-01");
        jedis.hmset("order:4", order4);

        jedis.lpush("user:1:order", "order:4");

        List<String> keys = jedis.lrange("user:1:order", 0, -1);
        for(String key : keys){
            System.out.println(jedis.hgetAll(key));
        }


        List<String> str = new ArrayList<>();
        //str.add("122");
        String [] res = str.toArray(new String [str.size()]);


        try {
            Long res11 = jedis.rpush("zlx-111", res);
        }catch (Exception w){
            w.printStackTrace();
        }
        System.out.println("--------");

    }
}
